//
// Created by zain on 2017/3/1.
//

#include "ShadowMaterial.h"

ZainGL::ShadowMaterial::ShadowMaterial(const GLchar *pathV, const GLchar *pathF,
                                       std::unordered_map<std::string, ZainTL::FileDatas> *bufferMap) : Material(pathV,
                                                                                                                 pathF,
                                                                                                                 bufferMap) {}

void
ZainGL::ShadowMaterial::update(glm::mat4 viewMat, glm::vec3 viewPos, glm::mat4 projMat, std::vector<Light *> lights,
                               GLfloat screenW, GLfloat screemH) {
    active();
    Light *directionalLight=lights[0];
    glUniformMatrix4fv(glGetUniformLocation(mShaderLoc, "lightProjection"), 1, GL_FALSE, value_ptr(
            directionalLight->getProjection(screenW, screemH)));
    glUniformMatrix4fv(glGetUniformLocation(mShaderLoc, "lightView"), 1, GL_FALSE, value_ptr(directionalLight->getViewMatrix()));
}
